package cn.edu.sdjzu.xg23.kcsj01_backend.controller;

import cn.edu.sdjzu.xg23.kcsj01_backend.controller.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.entity.LiteratureDatabase;
import cn.edu.sdjzu.xg23.kcsj01_backend.service.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.utils.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.entity.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.mapper.*;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
public class LiteratureDatabaseAsPaperController {
    @Autowired
    private LiteratureDatabaseAsPaperService literatureDatabaseAsPaperService;

    @GetMapping("/literatureDatabaseAsPaper")
    public Result get(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody(required = false) LiteratureDatabaseAsPaper literatureDatabaseAsPaper) {

        PageInfo<LiteratureDatabaseAsPaper> literatureDatabaseAsPaperPageInfo = literatureDatabaseAsPaperService.get(pageNum, pageSize, literatureDatabaseAsPaper);
        System.out.println(literatureDatabaseAsPaperPageInfo);
        return Result.success(literatureDatabaseAsPaperPageInfo);
    }

    @PostMapping("/literatureDatabaseAsPaper")
    public Result save(@RequestBody LiteratureDatabaseAsPaper literatureDatabaseAsPaper) {
        return Result.success(literatureDatabaseAsPaperService.save(literatureDatabaseAsPaper));
    }

    @PutMapping("/literatureDatabaseAsPaper")
    public Result update(@RequestBody LiteratureDatabaseAsPaper literatureDatabaseAsPaper) {
        return Result.success(literatureDatabaseAsPaperService.update(literatureDatabaseAsPaper));
    }

    @DeleteMapping("/literatureDatabaseAsPaper/{id}")
    public Result delete(@PathVariable long id) {
        return Result.success(literatureDatabaseAsPaperService.delete(id));
    }
}
